<? use_helper('Date') ?>

<h1>EVE Ladder</h1>

<? if (isset($to_validate) && count($to_validate)) { ?>
	<h2>Challenges you need to validate</h2>
	<table cellpadding="0" cellspacing="0" border="0">
	<?php foreach ($to_validate as $challenge) { ?>
	<tr>
		<td>
			<?php echo link_to($challenge->getP1()->getUsername(), 'player/details?player=' . $challenge->getP1Id())?>
			beats you at
			<?php echo format_date($challenge->getCreatedAt()) ?>
		</td>
		<td>
			<?php echo form_tag('challenge/validate') ?>
				<?php echo input_hidden_tag('challenge', $challenge->getId()) ?>
				<?php echo submit_image_tag('/web/images/accept.png', array(
					'onclick' => "if (!confirm('Are you sure you want to validate this challenge ?')) return false ;"
				)) ?>
			</form>
		</td><td>
			<?php echo form_tag('challenge/refuse') ?>
				<?php echo input_hidden_tag('challenge', $challenge->getId()) ?>
				<?php echo submit_image_tag('/web/images/delete.png', array(
					'onclick' => "if (!confirm('Are you sure you want to refuse this challenge ?')) return false ;"
				)) ?>
			</form>
		</td>
	</tr>
	<?php } ?>
	</table>
<? } ?>

<h2>Top <?php echo sfConfig::get('app_pager_homepage_ranking') ?></h2>

<?php include_partial('challenge/ranking', array('ranking' => $ranking)) ?>
<p class="big_purple"><?php echo link_to('see the whole ranking', 'challenge/ranking') ?></p>

<h2>Last <?php echo sfConfig::get('app_pager_homepage_challenges') ?> Challenges</h2>

<?php include_partial('challenge/list', array('challenges' => $challenges)) ?>
<p class="big_purple"><?php echo link_to('see all the challenges', 'challenge/list') ?></p>